<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
    <script type="text/javascript">
        window.onload = function () {
            var canvas = document.querySelector("canvas");
            //获取canvas元素

            if (canvas.getContext) {
                var ctx = canvas.getContext("2d");
                ctx.fillStyle = "rgb(200,50,0)";//填充颜色
                //绘制矩形
                ctx.fillRect(50, 50, 50, 50);
            }
        };


    </script>
</head>
<body>
<canvas width="150" height="150">不支持canvas</canvas>

</body>
</html>